package com.lzx.demo.work2;

/**
 * @author 程序员星星
 * @date 2023/3/23
 * @Description
 */
public class Demo {
    private static class CPU {
        int speed;

        void setSpeed(int m) {
            speed = m;
        }

        int getSpeed() {
            return speed;
        }
    }

    private static class HardDisk {
        int amount;

        void setAmount(int m) {
            amount = m;
        }

        int getAmount() {
            return amount;
        }
    }

    private static class PC {
        CPU cpu;
        HardDisk HD;

        void setCPU(CPU c) {
            cpu = c;
        }

        void setHardDisk(HardDisk h) {
            HD = h;
        }

        void show() {
            System.out.println("CPU的速度为:" + cpu.getSpeed());
            System.out.println("硬盘的容量为:" + HD.getAmount());
        }
    }

    public static void main(String[] args) {
        CPU cpu = new CPU();
        cpu.setSpeed(2200);
        HardDisk disk = new HardDisk();
        disk.setAmount(200);
        PC pc = new PC();
        pc.setCPU(cpu);
        pc.setHardDisk(disk);
        pc.show();
    }
}
